/*
 * drv8305.h
 *
 *  Created on: 2024年10月8日
 *      Author: zizhong
 */

#ifndef USER_INC_DRV8305_H_
#define USER_INC_DRV8305_H_

#include "board.h"


#define  DRV8305_CTRLMODE_READ   ((uint16_t)1 << 15)   //!< Read Mode
#define  DRV8305_CTRLMODE_WRITE  ((uint16_t)0 << 15)   //!< Write Mode

typedef enum
{
  Address_Status_1  = 1 << 11,   //!< Status Register 1
  Address_Status_2  = 2 << 11,   //!< Status Register 2
  Address_Status_3  = 3 << 11,   //!< Status Register 3
  Address_Status_4  = 4 << 11,   //!< Status Register 4
  Address_Control_5 = 5 << 11,   //!< Control Register 5
  Address_Control_6 = 6 << 11,   //!< Control Register 6
  Address_Control_7 = 7 << 11,   //!< Control Register 7
//  Address_Control_8 = 8 << 11,   //!< Control Register 8
  Address_Control_9 = 9 << 11,   //!< Control Register 9
  Address_Control_A = 10 << 11,  //!< Control Register A
  Address_Control_B = 11 << 11,  //!< Control Register B
  Address_Control_C = 12 << 11   //!< Control Register C
} DRV8305_Address_e;

#define DRV8305_DATA_MASK                   (0x07FF)

uint16_t DRV8305_readSPI(uint32_t spiBase,
                         const DRV8305_Address_e regAddr,
                         uint16_t CS_PIN,
                         uint16_t * rxTimeOutFlag);

uint16_t DRV8305_buildCtrlWord(const uint16_t ctrlMode,
                                             const DRV8305_Address_e regAddr,
                                             const uint16_t data);



#endif /* USER_INC_DRV8305_H_ */
